Next | Prev | Up | Top | Contents | Index

Using the Hardware Inventory

The hardware inventory is used by users, administrators, and programmers.


Contents of the Inventory

Using database terminology, the hardware inventory consists of a single table with the following columns:

ClassA code for the class of device; for example, audio, disk, processor, or network.
TypeA code for the type of device within its class; for example, FPU and CPU types within the processor class.
ControllerWhen applicable, the number of the controller, board, or attachment.
UnitWhen applicable, the logical unit or device within a Controller number.
StateA descriptive number, such as the CPU model number.


Displaying the Inventory with hinv

The hinv command formats all or selected rows of the inventory table for display (see the hinv(1) reference page), translating the numbers to readable form. The user or system administrator can use command options to select a class of entries or certain specific device types by name. The class or type can be qualified with a unit number and a controller number. For example,

hinv -c disk -b 1 -u 4

displays information about disk 4 on controller 1.

You can use hinv to check the result of installing new hardware. The new hardware should show up in the report after the system is booted following installation, provided that the associated device driver was called and was written correctly.

A full inventory report (hinv -v) is almost mandatory documentation for a software problem report, either submitted by your user to you, or by you to Silicon Graphics.


Testing the Inventory In Software

Within a shell script, you can test the output of hinv most conveniently in the command exit status. The command sets exit status of 0 when it finds or reports any items. It sets status of 1 when it finds no items. The code in Example 2-1 could be used in a shell script to test the existence of a disk controller.

Example 2-1 : Testing the Hardware Inventory in a Shell Script

if hinv -s -c disk -b 1;
   then ;
   else echo No second disk controller;
fi ;
You can access the inventory table in a C program using the functions documented in the getinvent(3) reference page. The only access method supported is a sequential scan over the table, viewing all entries. Three functions permit access:

These functions use static variables and should only be used by a single process within an address space. Reentrant forms of the same functions, which can safely be used in a multithreaded process, are also available (see getinvent(3)). Example 2-2 demonstrates the use of these functions.

The format of one inventory table row is declared as type inventory_t in the sys/invent.h header file. This header file also supplies symbolic names for all the class and type numbers that can appear in the table, as well as containing commentary explaining the meanings of some of the numbers.

Example 2-2 : Function Returning Type Code for CPU Module

#include <stddef.h> /* for NULL */
#include <invent.h> /* includes sys/invent.h */
int getIPtypeCode()
{
   inv_state_t * pstate = NULL;
   inventory_t * work;
   int ret = 0;
   setinvent_r(&pstate);
   do {
      work = getinvent_r(pstate);
      if ( (INV_PROCESSOR == work->inv_class)
      &&   (INV_CPUBOARD == work->inv_type) )
         ret = work->inv_state;
   } while (!ret)
   endinvent_r(pstate); /* releases pstate-> */
   return ret;
}

Next | Prev | Up | Top | Contents | Index